package network;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class TcpDictServer extends TcpEchserver{
    Map<String, String> dict = new HashMap<>();
    public TcpDictServer(int port) throws IOException {
        super(port);
        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        dict.put("bird", "小鸟");
        dict.put("apple", "苹果");
        dict.put("banana", "香蕉");
        dict.put("strawberry", "草莓");
        dict.put("watermelon", "西瓜");
        //...
    }

    @Override
    public String process(String requst) {
        //查字典
        return dict.getOrDefault(requst, "当前单词没有查到结果");
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer server = new TcpDictServer(9090);
        server.start();
    }
}
